package simutanque;

import java.awt.Color;
import java.io.File;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;

/*
 * To change this template, choose Tools | Templates and open the template in
 * the editor.
 */
/**
 *
 * @author Augusto Wolf
 */
public class TelaPrincipal extends javax.swing.JFrame {

    /**
     * Creates new form TelaPrincipal
     */
    public TelaPrincipal() {
        initComponents();
        t.start();
        tt.start();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jFormattedTextField1 = new javax.swing.JFormattedTextField();
        jdEntrada = new javax.swing.JDialog();
        jPanel8 = new javax.swing.JPanel();
        jftfAmplitude = new javax.swing.JFormattedTextField();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jftfPeriodo = new javax.swing.JFormattedTextField();
        jLabel12 = new javax.swing.JLabel();
        jcbTipoFuncao = new javax.swing.JComboBox();
        jPanel9 = new javax.swing.JPanel();
        jftfPhDeEntrada = new javax.swing.JFormattedTextField();
        jPanel10 = new javax.swing.JPanel();
        jftfTemperaturaDeEntrada = new javax.swing.JFormattedTextField();
        jftfAutomatico = new javax.swing.JFormattedTextField();
        jcbAutomatico = new javax.swing.JCheckBox();
        jDialog1 = new javax.swing.JDialog();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jtfNome = new javax.swing.JTextField();
        jftfAltura = new javax.swing.JFormattedTextField();
        jftfLargura = new javax.swing.JFormattedTextField();
        jftfProfundidade = new javax.swing.JFormattedTextField();
        jftfVolumeInicial = new javax.swing.JFormattedTextField();
        jftfTemperaturaInicial = new javax.swing.JFormattedTextField();
        jcbTanques = new javax.swing.JComboBox();
        jLabel10 = new javax.swing.JLabel();
        jftfDiametroSaida = new javax.swing.JFormattedTextField();
        jftfPhInicial = new javax.swing.JFormattedTextField();
        jLabel11 = new javax.swing.JLabel();
        jButton10 = new javax.swing.JButton();
        jButton11 = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtTanques = new javax.swing.JTable();
        jPanel3 = new javax.swing.JPanel();
        jtbIniciar = new javax.swing.JToggleButton();
        jtbPausar = new javax.swing.JToggleButton();
        jPanel4 = new javax.swing.JPanel();
        jButton7 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jLabel14 = new javax.swing.JLabel();
        jftfVelocidade = new javax.swing.JFormattedTextField();
        jButton5 = new javax.swing.JButton();
        jPanel6 = new javax.swing.JPanel();
        jLabel13 = new labelVertical("");
        jPanel7 = new javax.swing.JPanel();
        jButton8 = new javax.swing.JButton();
        jButton9 = new javax.swing.JButton();
        jCheckBox1 = new javax.swing.JCheckBox();

        jFormattedTextField1.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#,##0.00########"))));

        jdEntrada.setTitle("SimuTanque - Entrada");
        jdEntrada.setMinimumSize(new java.awt.Dimension(378, 378));
        jdEntrada.setResizable(false);

        jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder("Vazão de Entrada"));

        jftfAmplitude.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter()));
        jftfAmplitude.setText("100");
        jftfAmplitude.setToolTipText("Definida em litros por minuto");
        jftfAmplitude.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                Entrou(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                Saiu(evt);
            }
        });

        jLabel8.setText("Amplitude:");

        jLabel9.setText("Período:");

        jftfPeriodo.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter()));
        jftfPeriodo.setText("10000");
        jftfPeriodo.setToolTipText("Definida em ms");
        jftfPeriodo.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                Entrou(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                Saiu(evt);
            }
        });

        jLabel12.setText("Tipo de Função:");

        jcbTipoFuncao.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Linear", "Senoidal", "Quadrática", "| Senoidal |", "Triangular" }));
        jcbTipoFuncao.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                Entrou(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                Saiu(evt);
            }
        });

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel12)
                    .addComponent(jLabel9)
                    .addComponent(jLabel8))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jftfAmplitude)
                    .addComponent(jftfPeriodo, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jcbTipoFuncao, 0, 220, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jftfAmplitude, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jftfPeriodo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(jcbTipoFuncao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder("PH de Entrada"));

        jftfPhDeEntrada.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter()));
        jftfPhDeEntrada.setText("5");
        jftfPhDeEntrada.setToolTipText("Varia de 0 à 14");
        jftfPhDeEntrada.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                Entrou(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                Saiu(evt);
            }
        });

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jftfPhDeEntrada)
                .addContainerGap())
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jftfPhDeEntrada, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel10.setBorder(javax.swing.BorderFactory.createTitledBorder("Temperatura de Entrada"));

        jftfTemperaturaDeEntrada.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter()));
        jftfTemperaturaDeEntrada.setText("100");
        jftfTemperaturaDeEntrada.setToolTipText("Definida em graus Celsius");
        jftfTemperaturaDeEntrada.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                Entrou(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                Saiu(evt);
            }
        });

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jftfTemperaturaDeEntrada)
                .addContainerGap())
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jftfTemperaturaDeEntrada, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jdEntradaLayout = new javax.swing.GroupLayout(jdEntrada.getContentPane());
        jdEntrada.getContentPane().setLayout(jdEntradaLayout);
        jdEntradaLayout.setHorizontalGroup(
            jdEntradaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jdEntradaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jdEntradaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jdEntradaLayout.setVerticalGroup(
            jdEntradaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jdEntradaLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jftfAutomatico.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter()));
        jftfAutomatico.setText("1000");
        jftfAutomatico.setToolTipText("Tempo em ms, não pode ser inferior a 100");
        jftfAutomatico.setMaximumSize(new java.awt.Dimension(999999, 22));

        jcbAutomatico.setText("Atualização Atumática:");
        jcbAutomatico.setMaximumSize(new java.awt.Dimension(999999, 999999));

        jDialog1.setTitle("SimuTanque - AJUDA");
        jDialog1.setMinimumSize(new java.awt.Dimension(739, 539));

        jTextArea1.setEditable(false);
        jTextArea1.setColumns(20);
        jTextArea1.setLineWrap(true);
        jTextArea1.setRows(5);
        jTextArea1.setText("SimuTanque??\n\nDados do ambiente\nAmbiente de desenvolvimento: NetBeans? IDE 7.1.2 (Build 201204101705)\nVersão do Java: 1.7.0_01; Java HotSpot?(TM) Client VM 21.1-b02\nVersão do Sistema: Windows 7 versão 6.1 executando em x86; Cp1252; pt_BR (nb)\n\nDados do projeto\nNúmero de Pacotes: 2\nNúmero de classes: 15\nBibliotecas Utilizadas: 1\n\nTelas, painéis e campos:\n\n\nPropriedades do Tanque\nNome >> Nome que será dado ao tanque (Não pode repetir)\nLargura >> Largura do tanque em metros\nProfundidade >> Profundidade do tanque em metros\nAltura >> Altura do tanque em metros\nDiâmetro de Saída >> Diâmetro do cano de saída em metros\nVolume Inicial >> Volume inicial do tanque em litros\nTemperatura Inicial >> Temperatura inicial do líquido em graus Celsius (0-100)\nPH Inicial >> PH inicial do líquido (0-14)\nTanque Anterior >> Para utilizar as saídas de outro tanque como entradas do tanque atual (Quando selecionado não é possível definir parâmetros de entrada)\nEntrada >> Define as opções de entrada para o tanque (só pode ser utilizado se não for selecionado nenhum tanque anterior)\nAmplitude >> Amplitude da função de entrada em litros (pico a pico)\nPeríodo >> Período da função de entrada em milissegundos;\nTipo de Função >> Tipo de função de entrada\nLinear >> Vazão de entrada é a própria amplitude\nSenoidal >> Vazão de entrada é uma curva senoidal\nQuadrática >> Vazão de entrada é uma onda quadrática ora igual a Amplitude ora valendo zero\n| Senoidal | >> Vazão de entrada é uma função senoidal espelhada para cima\nTriangular >> Vazão de entrada é uma curva triangular\nTemperatura >> Temperatura de entrada em graus Celsius (0-100)\nPH >> PH de entrada (0-14)\n\nAções de Cadastro dos Tanques\nLimpar >> Limpa campos de cadastro do tanque\nNovo >> Cria um novo Tanque (se tudo ocorrer corretamente os campos serão limpos)\nSalvar >> Altera os dados do tanque (se tudo ocorrer corretamente os campos serão limpos)\nApagar >> Apaga o Tanque (se tudo ocorrer corretamente o tanque será removido da listagem)\n\nImportação e exportação:\nImportar >> Importa os tanques salvos em um arquivo csv\nExportar >> Exporta os tanques para um arquivo csv\nSalvar Dados >> Ao iniciar a simulação será solicitado uma pasta, onde todos os dados de simulação de cada tanque serão salvos (será criado um arquivo por tanque).\n\nSimulação:\nIniciar >> Inicia a simulação | Para a simulação (ao parar uma simulação os tanques retornarão ao seu estado original e todas as telas de exibição serão fechadas)\nPausar >> Pausa a simulação | Continua a simulação\nOpções de Visualização:\nExibir Tree >> Exibe uma tela mostrando a relação dos tanques\nExibir Tela de Comparação >> Exibe uma tela onde os tanques podem ser vistos lado a lado\nVelocidade de Simulação >> Utilizado para acelerar o reduzir a animação (-10 a 10 ou de 0,1 a 10)\nAtualizar Agora >> Atualiza a Lista de Tanques\n\nLista de Tanques\nNome >> Nome do tanque\nLargura >> Largura do tanque em metros\nProfundidade >> Profundidade do tanque em metros\nAltura >> Altura do tanque em metros\nDiâmetro de Saída >> Diâmetro do cano de saída do tanque em metros\n\n\nTela Compara Tanques\nNome >> Nome do Tanque\nNível do Tanque >> Simulação da altura do liquido no tanque\nVolume Atual >> Volume de líquido no tanque em litros\nTemperatura Atual >> Temperatura do líquido em graus Celsius\nPH Atual >> PH do líquido\nVazão de Saída >> Vazão de saída em litros por segundo\nTipo de Função de Entrada >> Tipo de função de entrada (caso seja selecionado um tanque anterior o valor é \"-\")\nVazão de Entrada >> Vazão de entrada em litros por segundo\nTemperatura de Entrada >> Temperatura de entrada em graus Celsius\nPH de Entrada >> PH de entrada\nTempo >> Tempo simulado decorrido\n\n\nTela Tanque\nNível >> Nível de líquido no tanque\nNome >> Nome do Tanque\nLargura >> Largura do tanque em metros\nProfundidade >> Profundidade do tanque em metros\nAltura >> Altura do tanque em metros\nDiâmetro de Saída >> Diâmetro do cano de saída do tanque em metros\nVolume Máximo >> Volume máximo do tanque em litros\nVolume Inicial >> Volume inicial do tanque em litros\nTemperatura Inicial >> Temperatura inicial do tanque em graus Celsius\nPH Inicial >> PH inicial do tanque\nTanque Anterior >> Nome do tanque anterior (caso não seja selecionado nenhum tanque anterior o valor é \"-\")\nAmplitude >> Amplitude da função de entrada em litros (pico a pico)\nPeríodo >> Período da função de entrada em milissegundos;\nTipo de Função >> Tipo de função de entrada (caso seja selecionado um tanque anterior o valor é \"-\")\nVazão de Entrada >> Vazão de entrada do tanque em litros por segundo\nTemperatura de Entrada >> Temperatura de entrada do tanque em graus Celsius\nPH de Entrada >> PH de entrada\nVolume Atual >> Volume atual do tanque em litros\nVazão de Saída >> Vazão de saída do tanque em litros por segundo\nTemperatura de Saída >> Temperatura de saída do tanque em graus Celsius (igual a temperatura atual)\nPH de Saída >> PH de saída do tanque (igual ao PH atual)\n");
        jScrollPane2.setViewportView(jTextArea1);

        javax.swing.GroupLayout jDialog1Layout = new javax.swing.GroupLayout(jDialog1.getContentPane());
        jDialog1.getContentPane().setLayout(jDialog1Layout);
        jDialog1Layout.setHorizontalGroup(
            jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 739, Short.MAX_VALUE)
        );
        jDialog1Layout.setVerticalGroup(
            jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 539, Short.MAX_VALUE)
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("SimuTanque");

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Tanque"));

        jLabel1.setText("Nome:");

        jLabel2.setText("Largura:");

        jLabel3.setText("Profundidade:");

        jLabel4.setText("Altura:");

        jLabel5.setText("Volume Inicial:");

        jLabel6.setText("Temperatura Inicial:");

        jLabel7.setText("Tanque Anterior:");

        jtfNome.setText("T1");
        jtfNome.setToolTipText("Dois tanques não podem ter o mesmo nome");
        jtfNome.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                Entrou(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                Saiu(evt);
            }
        });

        jftfAltura.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter()));
        jftfAltura.setText("2");
        jftfAltura.setToolTipText("Definida em metros");
        jftfAltura.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                Entrou(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                Saiu(evt);
            }
        });

        jftfLargura.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter()));
        jftfLargura.setText("1");
        jftfLargura.setToolTipText("Definida em metros");
        jftfLargura.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                Entrou(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                Saiu(evt);
            }
        });

        jftfProfundidade.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter()));
        jftfProfundidade.setText("1");
        jftfProfundidade.setToolTipText("Definida em metros");
        jftfProfundidade.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                Entrou(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                Saiu(evt);
            }
        });

        jftfVolumeInicial.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter()));
        jftfVolumeInicial.setText("0");
        jftfVolumeInicial.setToolTipText("Definido em litros");
        jftfVolumeInicial.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                Entrou(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                Saiu(evt);
            }
        });

        jftfTemperaturaInicial.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter()));
        jftfTemperaturaInicial.setText("0");
        jftfTemperaturaInicial.setToolTipText("Definida em graus Celsius");
        jftfTemperaturaInicial.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                Entrou(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                Saiu(evt);
            }
        });

        jcbTanques.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-" }));
        jcbTanques.setToolTipText("Entrada é a saída de outro tanque");
        jcbTanques.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jcbTanquesItemStateChanged(evt);
            }
        });
        jcbTanques.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                Entrou(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                Saiu(evt);
            }
        });

        jLabel10.setText("Diâmetro de Saída");

        jftfDiametroSaida.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter()));
        jftfDiametroSaida.setText("0");
        jftfDiametroSaida.setToolTipText("Definido em metros");
        jftfDiametroSaida.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                Entrou(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                Saiu(evt);
            }
        });

        jftfPhInicial.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter()));
        jftfPhInicial.setText("7");
        jftfPhInicial.setToolTipText("Varia de 0 à 14");
        jftfPhInicial.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                Entrou(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                Saiu(evt);
            }
        });

        jLabel11.setText("PH Inicial:");

        jButton10.setText("Definir Entrada");
        jButton10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton10ActionPerformed(evt);
            }
        });

        jButton11.setText("Ajuda");
        jButton11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton11ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(46, 46, 46)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel10)
                    .addComponent(jLabel7)
                    .addComponent(jLabel6)
                    .addComponent(jLabel5)
                    .addComponent(jLabel4)
                    .addComponent(jLabel3)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2)
                    .addComponent(jLabel11))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jftfPhInicial)
                    .addComponent(jtfNome)
                    .addComponent(jftfAltura)
                    .addComponent(jftfLargura, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jftfProfundidade, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jftfVolumeInicial)
                    .addComponent(jftfTemperaturaInicial, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jcbTanques, 0, 169, Short.MAX_VALUE)
                    .addComponent(jftfDiametroSaida, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButton10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jtfNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jftfLargura, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jftfProfundidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jftfAltura, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(jftfDiametroSaida, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jftfVolumeInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jftfTemperaturaInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(jftfPhInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jcbTanques, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Ações"));
        jPanel2.setMaximumSize(new java.awt.Dimension(10, 10));
        jPanel2.setMinimumSize(new java.awt.Dimension(247, 230));
        jPanel2.setPreferredSize(new java.awt.Dimension(247, 230));
        jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.PAGE_AXIS));

        jButton1.setText("Limpar");
        jButton1.setMaximumSize(new java.awt.Dimension(999999, 999999));
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jPanel2.add(jButton1);

        jButton2.setText("Novo");
        jButton2.setMaximumSize(new java.awt.Dimension(999999, 999999));
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        jPanel2.add(jButton2);

        jButton3.setText("Salvar");
        jButton3.setMaximumSize(new java.awt.Dimension(999999, 999999));
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });
        jPanel2.add(jButton3);

        jButton4.setText("Apagar");
        jButton4.setMaximumSize(new java.awt.Dimension(999999, 999999));
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });
        jPanel2.add(jButton4);

        jtTanques.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Nome", "Largura", "Profundidade", "Altura", "Diaâmetro de Saída"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.Double.class, java.lang.Double.class, java.lang.Double.class, java.lang.Double.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jtTanques.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jtTanquesMouseClicked(evt);
            }
        });
        jtTanques.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                Entrou(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                Saiu(evt);
            }
        });
        jScrollPane1.setViewportView(jtTanques);

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Simulação"));
        jPanel3.setMaximumSize(new java.awt.Dimension(10, 10));
        jPanel3.setMinimumSize(new java.awt.Dimension(247, 230));
        jPanel3.setLayout(new javax.swing.BoxLayout(jPanel3, javax.swing.BoxLayout.LINE_AXIS));

        jtbIniciar.setText("Iniciar");
        jtbIniciar.setMaximumSize(new java.awt.Dimension(999999, 999999));
        jtbIniciar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtbIniciarActionPerformed(evt);
            }
        });
        jPanel3.add(jtbIniciar);

        jtbPausar.setText("Pausar");
        jtbPausar.setMaximumSize(new java.awt.Dimension(999999, 999999));
        jtbPausar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtbPausarActionPerformed(evt);
            }
        });
        jPanel3.add(jtbPausar);

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Opções"));
        jPanel4.setMaximumSize(new java.awt.Dimension(10, 10));

        jButton7.setText("Exibir Tela Comparação");
        jButton7.setMaximumSize(new java.awt.Dimension(999999, 999999));
        jButton7.setMinimumSize(new java.awt.Dimension(193, 25));
        jButton7.setPreferredSize(new java.awt.Dimension(193, 75));
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

        jButton6.setText("Exibir Tree");
        jButton6.setMaximumSize(new java.awt.Dimension(999999, 999999));
        jButton6.setMinimumSize(new java.awt.Dimension(193, 25));
        jButton6.setPreferredSize(new java.awt.Dimension(193, 75));
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        jPanel5.setMaximumSize(new java.awt.Dimension(193, 75));
        jPanel5.setMinimumSize(new java.awt.Dimension(193, 75));

        jLabel14.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel14.setText("Velocidade de Simulação:");

        jftfVelocidade.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0.00"))));
        jftfVelocidade.setText("1");
        jftfVelocidade.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jftfVelocidadeFocusLost(evt);
            }
        });
        jftfVelocidade.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jftfVelocidadeKeyTyped(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)
                    .addComponent(jftfVelocidade))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, 21, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jftfVelocidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jButton5.setText("Atualizar Agora");
        jButton5.setMaximumSize(new java.awt.Dimension(999999, 999999));
        jButton5.setMinimumSize(new java.awt.Dimension(193, 25));
        jButton5.setPreferredSize(new java.awt.Dimension(193, 75));
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jButton6, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
            .addComponent(jButton7, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jButton5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addGap(1, 1, 1)
                .addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
        );

        jPanel6.setBackground(new java.awt.Color(255, 191, 191));
        jPanel6.setMaximumSize(new java.awt.Dimension(77, 387));
        jPanel6.setMinimumSize(new java.awt.Dimension(77, 387));
        jPanel6.setPreferredSize(new java.awt.Dimension(77, 387));
        jPanel6.setLayout(new java.awt.BorderLayout());

        jLabel13.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        jLabel13.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel13.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jPanel6.add(jLabel13, java.awt.BorderLayout.CENTER);

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder("Arquivos"));
        jPanel7.setLayout(new javax.swing.BoxLayout(jPanel7, javax.swing.BoxLayout.PAGE_AXIS));

        jButton8.setText("Importar");
        jButton8.setToolTipText("Importa tanques salvos");
        jButton8.setMaximumSize(new java.awt.Dimension(999999, 999999));
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });
        jPanel7.add(jButton8);

        jButton9.setText("Exportar");
        jButton9.setToolTipText("Exporta Tanques salvos");
        jButton9.setMaximumSize(new java.awt.Dimension(999999, 999999));
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton9ActionPerformed(evt);
            }
        });
        jPanel7.add(jButton9);

        jCheckBox1.setText("Salvar Dados");
        jCheckBox1.setToolTipText("Salva dados da simulação");
        jPanel7.add(jCheckBox1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jScrollPane1))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 175, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jcbTanquesItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jcbTanquesItemStateChanged
        if (jcbTanques.getSelectedIndex() != 0) {
            if (limpaEntradas) {
                jftfAmplitude.setEnabled(false);
                jftfTemperaturaDeEntrada.setEnabled(false);
                jftfPhDeEntrada.setEnabled(false);
                jButton10.setEnabled(false);
                jdEntrada.setVisible(false);
                jftfAmplitude.setText("");
                jftfTemperaturaDeEntrada.setText("");
                jftfPhDeEntrada.setText("");
            }
        } else {
            jButton10.setEnabled(true);
            jftfAmplitude.setEnabled(true);
            jftfTemperaturaDeEntrada.setEnabled(true);
            jftfPhDeEntrada.setEnabled(true);
        }
    }//GEN-LAST:event_jcbTanquesItemStateChanged

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        Tanque t = new Tanque(jtfNome.getText(),
                Double.parseDouble(jftfLargura.getText().replace(".", "").replace(",", ".")),
                Double.parseDouble(jftfProfundidade.getText().replace(".", "").replace(",", ".")),
                Double.parseDouble(jftfAltura.getText().replace(".", "").replace(",", ".")),
                Double.parseDouble(jftfVolumeInicial.getText().replace(".", "").replace(",", ".")),
                Double.parseDouble(jftfTemperaturaInicial.getText().replace(".", "").replace(",", ".")),
                Double.parseDouble(jftfPhInicial.getText().replace(".", "").replace(",", ".")),
                Double.parseDouble(jftfDiametroSaida.getText().replace(".", "").replace(",", ".")));
        Gerencia g = Gerencia.obterInstancia();
        int i = jcbTanques.getSelectedIndex() - 1;
        boolean ok = true;
        if (i >= 0) {
            Tanque ant = g.getTanque(i);
            //System.out.println(i + " " + ant.getNome());
            if (!g.tanqueJaUtilizado(ant.getNome())) {
                t.setAnterior(ant);
            } else {
                ok = false;
            }
        } else {
            ok = t.setAmplitude(Double.parseDouble(jftfAmplitude.getText().replace(".", "").replace(",", ".")));
            ok = t.setPeriodo(Double.parseDouble(jftfPeriodo.getText().replace(".", "").replace(",", ".")));
            ok = t.setTipoFuncao(jcbTipoFuncao.getSelectedIndex());
            ok = t.setTemperaturaDeEntrada(Double.parseDouble(jftfTemperaturaDeEntrada.getText().replace(".", "").replace(",", ".")));
            ok = t.setPhDeEntrada(Double.parseDouble(jftfPhDeEntrada.getText().replace(".", "").replace(",", ".")));
        }
        if (ok) {
            if (g.adicionar(t)) {
                limpar();
            } else {
                UTI.erro(this, "Erro ao alterar Tanque", "SimuTanque - ERRO");
            }
        } else {
            UTI.erro(this, "Erro ao alterar Tanque", "SimuTanque - ERRO");
        }
        atualizar();
        if (telaComp != null) {
            telaComp.atualiza();
        }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        atualizar();
    }//GEN-LAST:event_jButton5ActionPerformed

    private void Entrou(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_Entrou
        atualizarAutomatico(false);
    }//GEN-LAST:event_Entrou

    private void Saiu(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_Saiu
        atualizarAutomatico(true);
    }//GEN-LAST:event_Saiu

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        limpar();
        atualizar();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        Tanque t = new Tanque(jtfNome.getText(),
                Double.parseDouble(jftfLargura.getText().replace(".", "").replace(",", ".")),
                Double.parseDouble(jftfProfundidade.getText().replace(".", "").replace(",", ".")),
                Double.parseDouble(jftfAltura.getText().replace(".", "").replace(",", ".")),
                Double.parseDouble(jftfVolumeInicial.getText().replace(".", "").replace(",", ".")),
                Double.parseDouble(jftfTemperaturaInicial.getText().replace(".", "").replace(",", ".")),
                Double.parseDouble(jftfPhInicial.getText().replace(".", "").replace(",", ".")),
                Double.parseDouble(jftfDiametroSaida.getText().replace(".", "").replace(",", ".")));
        Gerencia g = Gerencia.obterInstancia();
        String ant = jcbTanques.getSelectedItem().toString();

        boolean ok = true;
        if (!ant.equals("-")) {
            //System.out.println("ant nome = " + ant);
            if (ant.equals(t.getNome())) {
                //System.out.println("anterior igual a atual");
                ok = false;
            } else if (ok && g.getTanque(t.getNome()).getAnterior().getNome().equals(ant)) {
                //System.out.println("não alterou tanque");
                t.setAnterior(g.getTanque(ant));
                ok = true;
            } else if (ok && !g.tanqueJaUtilizado(ant)) {
                //System.out.println("ainda não utilizado");
                t.setAnterior(g.getTanque(ant));
                ok = true;
            } else {
                //System.out.println("else false");
                ok = false;
            }
        } else {
            ok = t.setAmplitude(Double.parseDouble(jftfAmplitude.getText().replace(".", "").replace(",", ".")));
            ok = t.setPeriodo(Double.parseDouble(jftfPeriodo.getText().replace(".", "").replace(",", ".")));
            ok = t.setTipoFuncao(jcbTipoFuncao.getSelectedIndex());
            //System.out.println("ok = " + ok);
            ok = t.setTemperaturaDeEntrada(Double.parseDouble(jftfTemperaturaDeEntrada.getText().replace(".", "").replace(",", ".")));
            //System.out.println("ok = " + ok);
            ok = t.setPhDeEntrada(Double.parseDouble(jftfPhDeEntrada.getText().replace(".", "").replace(",", ".")));
            //System.out.println("ok = " + ok);
        }
        //System.out.println("ok = " + ok);
        if (ok) {
            if (g.alterar(t)) {
                //System.out.println(t.toString());
                limpar();
            } else {
                UTI.erro(this, "Erro ao alterar Tanque\nCodigo 01", "SimuTanque - ERRO");
            }
        } else {
            UTI.erro(this, "Erro ao alterar Tanque\nCodigo 02", "SimuTanque - ERRO");
        }
        atualizar();
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        String nome = jtfNome.getText();
        if (UTI.confirmar(this, "Você realmente deseja apaga o tanque " + nome + "?", "SimuTanque - Aviso")) {
            Gerencia g = Gerencia.obterInstancia();
            boolean b = g.apagar(nome);
            if (!b) {
                UTI.erro(this, "Erro ao apagar tanque.\n"
                        + "Verifique se ele não está\n"
                        + "sendo utilizado como entrada\n"
                        + "de outro tanque.", "Simutanque - Erro");
            }
            atualizar();
        }
        if (telaComp != null) {
            telaComp.atualiza();
        }
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jtTanquesMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jtTanquesMouseClicked
        if (evt.getButton() == 3) {
            int linha = jtTanques.getSelectedRow();
            int col = jtTanques.getColumnCount();
            int colNome = -1;
            for (int i = 0; i < col; i++) {
                if (jtTanques.getColumnName(i).equals("Nome")) {
                    colNome = i;
                    break;
                }
            }
            String nome = jtTanques.getValueAt(linha, colNome).toString();
            Tanque tanque = Gerencia.obterInstancia().getTanque(nome);
            jtfNome.setText(tanque.getNome());
            jftfAltura.setText((tanque.getAltura() + "").replaceAll("\\.", ","));
            jftfDiametroSaida.setText((tanque.getDiametroSaida() + "").replaceAll("\\.", ","));
            jftfLargura.setText((tanque.getLargura() + "").replaceAll("\\.", ","));
            jftfProfundidade.setText((tanque.getProfundidade() + "").replaceAll("\\.", ","));
            jftfTemperaturaInicial.setText((tanque.getTemperaturaInicial() + "").replaceAll("\\.", ","));
            jftfVolumeInicial.setText((tanque.getVolumeInicial() + "").replaceAll("\\.", ","));
            jftfPhInicial.setText((tanque.getPhInicial() + "").replaceAll("\\.", ","));
            jftfVolumeInicial.setText((tanque.getVolumeInicial() + "").replaceAll("\\.", ","));
            try {
                jcbTanques.setSelectedIndex(Gerencia.obterInstancia().indexTanque(tanque.getAnterior().getNome()) + 1);
                jftfTemperaturaDeEntrada.setText("");
                jftfPhDeEntrada.setText("");
            } catch (Exception ex) {
                jcbTanques.setSelectedIndex(0);
                jftfAmplitude.setText((tanque.getAmplitude() + "").replaceAll("\\.", ","));
                jftfPeriodo.setText((tanque.getPeriodo() + "").replaceAll("\\.", ","));
                jcbTipoFuncao.setSelectedIndex(tanque.getTipoFuncao());
                jftfTemperaturaDeEntrada.setText((tanque.getTemperaturaDeEntrada() + "").replaceAll("\\.", ","));
                jftfPhDeEntrada.setText((tanque.getPhDeEntrada() + "").replaceAll("\\.", ","));

            }
        } else if (evt.getClickCount() == 2) {
            try {
                int linha = jtTanques.getSelectedRow();
                int col = jtTanques.getColumnCount();
                int colNome = -1;
                for (int i = 0; i < col; i++) {
                    if (jtTanques.getColumnName(i).equals("Nome")) {
                        colNome = i;
                        break;
                    }
                }
                String nome = jtTanques.getValueAt(linha, colNome).toString();
                Gerencia.obterInstancia().getTanque(nome).exibirTela(true);
            } catch (Exception e) {
            }
        }
    }//GEN-LAST:event_jtTanquesMouseClicked

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        atualizarTree();
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jtbIniciarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtbIniciarActionPerformed
        if (jtbIniciar.isSelected()) {
            jtbIniciar.setSelected(false);
            File f = null;
            boolean ok = true;
            if (jCheckBox1.isSelected()) {
                JFileChooser fc = new JFileChooser();
                fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
                int retval = fc.showSaveDialog(this);
                if (retval == JFileChooser.APPROVE_OPTION) {
                    f = fc.getSelectedFile();
                    ok = true;
                } else {
                    ok = false;
                }
            }
            if (ok) {
                Gerencia.obterInstancia().iniciar(jCheckBox1.isSelected(), f, Double.parseDouble(jftfVelocidade.getText().replace(".", "").replace(",", ".")));
                jtfNome.setEditable(false);
                jftfAltura.setEditable(false);
                jftfLargura.setEditable(false);
                jftfProfundidade.setEditable(false);
                jftfVolumeInicial.setEditable(false);
                jftfTemperaturaInicial.setEditable(false);
                jftfPhInicial.setEditable(false);
                jftfDiametroSaida.setEditable(false);
                jftfVelocidade.setEditable(false);
                jButton2.setEnabled(false);
                jButton4.setEnabled(false);
                jCheckBox1.setEnabled(false);
                jtbIniciar.setSelected(true);
            } else {
                UTI.aviso(this, "Você selecionou a opção de salvar os\n"
                        + "dados da simulação mas não selecionou\n"
                        + "nenhum arquivo.\nA simulação não pode iniciar.", "SimuTanque - Aviso");
            }
        } else {
            Gerencia.obterInstancia().parar();
            jtbPausar.setSelected(false);
            Gerencia.obterInstancia().pausar(jtbPausar.isSelected());
            if (telaComp != null) {
                telaComp.dispose();
                telaComp = null;
            }
            jtfNome.setEditable(true);
            jftfAltura.setEditable(true);
            jftfLargura.setEditable(true);
            jftfProfundidade.setEditable(true);
            jftfVolumeInicial.setEditable(true);
            jftfTemperaturaInicial.setEditable(true);
            jftfPhInicial.setEditable(true);
            jftfDiametroSaida.setEditable(true);
            jftfVelocidade.setEditable(true);
            jButton2.setEnabled(true);
            jButton4.setEnabled(true);
            jCheckBox1.setEnabled(true);
        }
    }//GEN-LAST:event_jtbIniciarActionPerformed

    private void jtbPausarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtbPausarActionPerformed
        if (jtbIniciar.isSelected()) {
            Gerencia.obterInstancia().pausar(jtbPausar.isSelected());
        } else {
            jtbPausar.setSelected(false);
        }
    }//GEN-LAST:event_jtbPausarActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        if (telaComp == null) {
            telaComp = new TelaComparaTanques();
        }
        telaComp.setVisible(true);
    }//GEN-LAST:event_jButton7ActionPerformed

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
        JFileChooser fc = new JFileChooser();
        Gerencia g = Gerencia.obterInstancia();
        int retval = fc.showOpenDialog(this);
        if (retval == JFileChooser.APPROVE_OPTION && fc.getSelectedFile().getAbsolutePath().endsWith(".csv")) {
            try {
                String linhas[] = UTI.abrirArquivo(fc.getSelectedFile()).split("\n");
                int cont = 0;
                for (int i = 0; i < linhas.length; i++) {
                    if (linhas[i].length() > 10) {
                        cont++;
                        g.adicionar(new Tanque(linhas[i]));
                    }
                }
                UTI.aviso(this, cont + " tanque(s) foram importados", "SimuTanque");
                atualizar();
            } catch (Exception ex) {
                Logger.getLogger(TelaPrincipal.class.getName()).log(Level.SEVERE, null, ex);
            }
        } else {
            UTI.aviso(this, "Arquivo Inválido", "Erro");
        }
    }//GEN-LAST:event_jButton8ActionPerformed

    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
        JFileChooser fc = new JFileChooser();
        Gerencia g = Gerencia.obterInstancia();
        int retval = fc.showSaveDialog(this);
        if (retval == JFileChooser.APPROVE_OPTION && fc.getSelectedFile().getAbsolutePath().endsWith(".csv")) {
            String s = "";
            for (int i = 0; i < g.totalTanques(); i++) {
                if (i != 0) {
                    s += "\n";
                }
                s += g.getTanque(i).toString();
            }
            UTI.gravarArquivo(fc.getSelectedFile(), s);
            UTI.aviso(this, g.totalTanques() + " tanque(s) foram exportados", "SimuTanque");
        } else {
            UTI.aviso(this, "Arquivo Inválido", "Erro");
        }
    }//GEN-LAST:event_jButton9ActionPerformed

    private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
        jdEntrada.setVisible(true);
    }//GEN-LAST:event_jButton10ActionPerformed

    private void jftfVelocidadeKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jftfVelocidadeKeyTyped
    }//GEN-LAST:event_jftfVelocidadeKeyTyped

    private void jftfVelocidadeFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jftfVelocidadeFocusLost
        double i = Double.parseDouble(jftfVelocidade.getText().replace(".", "").replace(",", "."));
        if (i < 0) {
            i = 1 / Math.abs(i);
        }
        if (i < 0.1) {
            i = 0.1;
        } else if (i > 10) {
            i = 10;
        }
        jftfVelocidade.setText((i + "").replaceAll("\\.", ","));
    }//GEN-LAST:event_jftfVelocidadeFocusLost

    private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed
        jDialog1.setVisible(true);
    }//GEN-LAST:event_jButton11ActionPerformed
    Thread t = new Thread() {
        public void run() {
            while (true) {
                while (!jcbAutomatico.isSelected()) {
                    try {
                        Thread.sleep(100);
                    } catch (Exception ex) {
                    }
                }
                try {
                    int i = 100;
                    try {
                        i = Integer.parseInt(jftfAutomatico.getText().replace(".", "").replace(",", "."));
                    } catch (Exception ex) {
                    }
                    if (i < 100) {
                        i = 100;
                        jftfAutomatico.setText("100");
                    }
                    Thread.sleep(i);
                } catch (Exception ex) {
                }
                atualizar();
            }
        }
    };
    Thread tt = new Thread() {
        public void run() {
            while (true) {
                try {
                    Thread.sleep(500);
                } catch (Exception ex) {
                }
                if (jtbIniciar.isSelected()) {
                    jPanel6.setBackground(new Color(153, 255, 153));
                    try {
                        Thread.sleep(500);
                    } catch (Exception ex) {
                    }
                    if (jtbPausar.isSelected()) {
                        jPanel6.setBackground(new Color(255, 191, 191));
                    } else {
                        jPanel6.setBackground(new Color(153, 255, 153));
                    }
                } else {
                    jPanel6.setBackground(new Color(255, 191, 191));
                }
            }
        }
    };
    TelaComparaTanques telaComp = null;

    public void pausar(boolean b) {
        jtbPausar.setSelected(b);
        Gerencia.obterInstancia().pausar(jtbPausar.isSelected());
    }

    private void limpar() {
        jtfNome.setText("");
        jftfAltura.setText("");
        jftfDiametroSaida.setText("");
        jftfLargura.setText("");
        jftfProfundidade.setText("");
        jftfTemperaturaInicial.setText("");
        jftfAmplitude.setText("");
        jftfPeriodo.setText("");
        jcbTipoFuncao.setSelectedIndex(0);
        jftfTemperaturaDeEntrada.setText("");
        jftfPhDeEntrada.setText("");
        jftfVolumeInicial.setText("");
        jftfPhInicial.setText("");
        jcbTanques.setSelectedIndex(0);
        jButton5.requestFocus();
    }
    private boolean antetior;
    private boolean limpaEntradas = true;

    public void atualizarAutomatico(boolean b) {
        if (b) {
            jcbAutomatico.setSelected(antetior);
            jcbAutomatico.setEnabled(true);
        } else {
            jcbAutomatico.setEnabled(false);
            antetior = jcbAutomatico.isSelected();
            jcbAutomatico.setSelected(false);
        }
    }

    public void atualizarTree() {

        Gerencia.obterInstancia().getTree();
        /*
         * DrawTreePanel jpTree = new DrawTreePanel(); jpTree.setParent(this);
         * jpTree.setTree(Gerencia.obterInstancia().getTree());
         * javax.swing.GroupLayout jPanel4Layout = new
         * javax.swing.GroupLayout(jpTree); jpTree.setLayout(jPanel4Layout);
         * jPanel4Layout.setHorizontalGroup(
         * jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0,
         * 184, Short.MAX_VALUE)); jPanel4Layout.setVerticalGroup(
         * jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0,
         * 444, Short.MAX_VALUE));
         */
    }

    public void atualizar() {
        //jPanel6.setToolTipText("Memoria utilizada = " + UTI.formatoNumero.format((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())/1024/1024)+" MB");
        jLabel13.setText("Memoria utilizada = " + UTI.formatoNumero.format((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024) + " KB");
        limpaEntradas = false;
        DefaultTableModel dtm = (DefaultTableModel) jtTanques.getModel();
        while (dtm.getRowCount() > 0) {
            dtm.removeRow(0);
        }
        jcbTanques.removeAllItems();
        jcbTanques.addItem("-");

        Gerencia g = Gerencia.obterInstancia();
        int totalTanques = g.totalTanques();
        for (int i = 0; i < totalTanques; i++) {
            Vector linha = new Vector();
            Tanque t = g.getTanque(i);

            //if (!g.tanqueJaUtilizado(t.getNome())) {
            jcbTanques.addItem(t.getNome());
            //}

            linha.add(t.getNome());
            linha.add(t.getLargura());
            linha.add(t.getProfundidade());
            linha.add(t.getAltura());
            linha.add(t.getDiametroSaida());
            dtm.addRow(linha);
        }

        jtTanques.setModel(dtm);
        TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(dtm);
        jtTanques.setRowSorter(sorter);
        limpaEntradas = true;
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JDialog jDialog1;
    private javax.swing.JFormattedTextField jFormattedTextField1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JCheckBox jcbAutomatico;
    private javax.swing.JComboBox jcbTanques;
    private javax.swing.JComboBox jcbTipoFuncao;
    private javax.swing.JDialog jdEntrada;
    private javax.swing.JFormattedTextField jftfAltura;
    private javax.swing.JFormattedTextField jftfAmplitude;
    private javax.swing.JFormattedTextField jftfAutomatico;
    private javax.swing.JFormattedTextField jftfDiametroSaida;
    private javax.swing.JFormattedTextField jftfLargura;
    private javax.swing.JFormattedTextField jftfPeriodo;
    private javax.swing.JFormattedTextField jftfPhDeEntrada;
    private javax.swing.JFormattedTextField jftfPhInicial;
    private javax.swing.JFormattedTextField jftfProfundidade;
    private javax.swing.JFormattedTextField jftfTemperaturaDeEntrada;
    private javax.swing.JFormattedTextField jftfTemperaturaInicial;
    private javax.swing.JFormattedTextField jftfVelocidade;
    private javax.swing.JFormattedTextField jftfVolumeInicial;
    private javax.swing.JTable jtTanques;
    private javax.swing.JToggleButton jtbIniciar;
    private javax.swing.JToggleButton jtbPausar;
    private javax.swing.JTextField jtfNome;
    // End of variables declaration//GEN-END:variables
}
